package org.qingke.mail.protal.controller;

import org.qingke.mail.protal.common.CatResult;
import org.qingke.mail.protal.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品分类控制器
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/itemcat")
public class ItemCatController {
   
	@Autowired
	private ItemCatService itemCatService;
	
	@RequestMapping("/list")
	public Object  queryByParentId(Long parentId,String callback){
		// 返回前端商品分类数据对象
		CatResult catResult=itemCatService.queryByParentId(parentId);
		// 将商品分类数据转换成支持页面跨域调用的jsonp请求方法的对象输出
		MappingJacksonValue mappingJacksonValue=new MappingJacksonValue(catResult);
		// 设置回调函数
		mappingJacksonValue.setJsonpFunction(callback);
		return mappingJacksonValue;
	}
}
